<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      #box {
        background-color: red;
        margin: 8px;
        width: 400px;
        height: 400px;
        text-align: center;
        line-height: 400px;
      }
    </style>
</head>
<body>
    <div id="box" >

    </div>
    <script>
        var box=document.getElementById('box');
        box.onmousemove=function(e){
            e=e||window.event;
            //clientX/Y是鼠标相对于浏览器（浏览器的有效区域）X/Y轴的距离
            //this.innerHTML=`clientX:${e.clientX};clientY:${e.clientY};X:${e.x};Y:${e.y};`

            //screenX/Y是相对于显示器的X/Y轴的距离

            //pageX/Y是相对于页面
            //this.innerHTML=`screenX:${e.screenX};screenY:${e.screenY};X:${e.x};Y:${e.y};`
            
            //相对于当前的事件源；
            this.innerHTML=`offsetX:${e.offsetX};offsetY:${e.offsetY};`
        }
    </script>
</body>
</html>